﻿using System;
using System.Collections.Generic;

using RexToy;

namespace RexToy.Cassandra
{
    static class ClusterPolicyFactory
    {
        public static IPoolingPolicy CreatePoolingPolicy(Pooling pooling)
        {
            pooling.ThrowIfEnumOutOfRange();
            switch (pooling)
            {
                case Pooling.ExhaustedBlock:
                    return new ExhaustedBlockPolicy();

                case Pooling.ExhaustedFail:
                    return new ExhaustedFailPolicy();
            }
            return null;
        }

        public static ILoadBalancePolicy CreateLoadBalancePolicy(LoadBalance loadBalance)
        {
            loadBalance.ThrowIfEnumOutOfRange();
            switch (loadBalance)
            {
                case LoadBalance.RoundRobin:
                    return new RoundRobinPolicy();

                case LoadBalance.LeastActive:
                    return new LeastActivePolicy();
            }
            return null;
        }
    }
}
